//
//  OrderTimeView.m
//  SDSY
//
//  Created by 蓝布鲁 on 2017/4/11.
//  Copyright (c) 2017 蓝布鲁. All rights reserved.
//

#import "OrderTimeView.h"
#import "TeacherOrderTimeCell.h"
#import "UserInfoModel.h"

@implementation OrderTimeView

- (instancetype)initWithFrame:(CGRect)frame {
    if(self = [super initWithFrame:frame]) {
        [self setupView];
    }
    return self;
}

#pragma mark - 自定义方法
-(void)setupView {
    // 初始化tableView
    self.tableView = [[UITableView alloc] initWithFrame:self.frame];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.tableFooterView = [[UIView alloc] init];
    [self addSubview:self.tableView];
}


#pragma mark - 重写方法
- (void)setFrame:(CGRect)frame {
    [super setFrame:frame];
    self.tableView.frame = self.bounds;
}

- (void)setTimes:(NSArray<TeacherOrderTimeModel *> *)times {
    _times = times;
    [self.tableView reloadData];
}

#pragma mark - UITableViewDelegate,UITableViewDataSource
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 45;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.times.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    TeacherOrderTimeCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ORDCELL"];

    if(cell == nil) {
        cell = [[TeacherOrderTimeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ORDCELL"];
    }
    cell.model = self.times[indexPath.row];
    return cell;

}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:tableView];
}
@end
